# -*- coding: utf-8 -*-
# Author: xiantingDeng
# File: validate_ls.py
# Time: 14:25


class AssertionIs():
    def __init__(self, log):
        self.__log = log

    def assert_code(self, code, expected_code):
        try:
            assert code == expected_code
            self.__log.info("AssertCode, actual[{}] == expect[{}]".format(
                code, expected_code)
            )
            return True
        except AssertionError:
            error_message = "StatusCodeError, status code[{}], expect code[{}]".format(code, expected_code)
            self.__log.error(error_message)
            raise AssertionError(error_message)

    def assert_msg(self, response, format, message):
        try:
            assert response[format] == message
            self.__log.info("AssertMsg,actual[{}] == expect[{}]".format(
                response[format], message)
            )
            return True
        except AssertionError:
            error_message = "StatusCodeError, status code[{}], expect code[{}]".format(response[format], message)
            self.__log.error(error_message)
            raise AssertionError(error_message)
